using GoogleMobileAds.Common.Mediation.UnityAds;
using UnityEngine;

namespace GoogleMobileAds.Android.Mediation.UnityAds
{
	public class UnityAdsClient : IUnityAdsClient
	{
		private static UnityAdsClient instance = new UnityAdsClient();

		public static UnityAdsClient Instance => instance;

		private UnityAdsClient()
		{
		}

		public void SetGDPRConsentMetaData(bool consent)
		{
			AndroidJavaObject @static = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
			AndroidJavaObject androidJavaObject = new AndroidJavaObject("java.lang.Boolean", consent);
			AndroidJavaObject androidJavaObject2 = new AndroidJavaObject("com.unity3d.ads.metadata.MetaData", @static);
			if (androidJavaObject2.Call<bool>("set", new object[2]
			{
				"gdpr.consent",
				androidJavaObject
			}))
			{
				string str = consent ? "true" : "false";
				MonoBehaviour.print("Setting UnityAds metadata with key 'gdpr.consent' to value: " + str);
				androidJavaObject2.Call("commit");
			}
		}
	}
}
